# coding:utf-8

from lib.base_ios import Base

from page.ios import train_rush_ticket_strategy_page, train_rush_order_fill_page, train_rush_order_details_page, \
    train_rush_ticket_order_list_page, train_index_page

__author__ = 'weixin.yuan'


class TrainRushOrderList(Base):
    """抢票订单列表"""
    def __init__(self, method_name):
        Base.__init__(self, method_name)

        """
        本页元素
        """
        self.add_rush_btn = train_rush_ticket_order_list_page.elements['添加抢票按钮']
        self.order_btn = train_rush_ticket_order_list_page.elements['订单详情按钮']
        self.rush_strategy_btn = train_rush_ticket_order_list_page.elements['抢票攻略按钮']

        """
        外部页面元素
        """
        self.rush_tick_btn = train_index_page.elements['抢票按钮']
        self.order_details_title = train_rush_order_details_page.elements['订单详情title']
        self.rush_ticket_strategy_title = train_rush_ticket_strategy_page.elements['抢票攻略title']
        self.rush_order_fill_title = train_rush_order_fill_page.elements['填写抢票信息title']

    def test_rush_order_list(self):
        """抢票订单列表"""
        self.open_schema_ios('6002')
        self.click(self.rush_tick_btn)

        if "北京" not in self.get_attr(self.rush_strategy_btn, 'name'):
            self.click(self.rush_strategy_btn)
            self.check(self.rush_ticket_strategy_title)
            self.back()

        self.click(self.add_rush_btn)  # 添加抢票
        self.check(self.rush_order_fill_title)
        self.back()

        self.click(self.order_btn)  # 订单详情

        self.check(self.order_details_title)
        self.back()
